#include "GeneBased.h"

SetID_Gene::SetID_Gene(vector<MapField*> vec, vector<GeneField*> genevec){
	auto it_map = vec.begin();
	auto it_gene = genevec.begin();

	while (it_map != vec.end()){
		if ((*it_map)->get_chr() < (*it_gene)->get_chr()){
			it_map++;
		}
		else if ((*it_map)->get_chr() > (*it_gene)->get_chr()){
			it_gene++;
		}
		else{
			if (((*it_map)->get_pos() >= (*it_gene)->get_start()) && ((*it_map)->get_pos() <= (*it_gene)->get_end())){
				setidvec.push_back(new MarkerSet((*it_gene)->get_genename(),(*it_map)));
				it_map++;
			}
			else if ((*it_map)->get_pos() < (*it_gene)->get_start()){
				it_map++;
			}
			else if ((*it_map)->get_pos() > (*it_gene)->get_end()){
				it_gene++;
				if (it_gene == genevec.end()) return;
			}
		}
	}
}